
import unittest

from Schedule.VacationDaysEvaluator import VacationDaysEvaluator
from Schedule.Doctors import Doctors
from Schedule.DoctorDaysOff import DoctorDaysOff 

class VacationDaysEvaluatorTestCases(unittest.TestCase):
    def setUp(self):
        self._initCount = dict()
        for i in range(0, len (Doctors().doctorNames)):
            self._initCount[i] = 0;
    
    def tearDown(self):
        pass

    def test_May1(self):
        
        month = 5
        schedule = [1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 1, 4]
        daysOff = DoctorDaysOff().getDaysOffByMonth(month)
        noCall = DoctorDaysOff().getNoCallByMonth(month)
        
        chromosome = [0, 4, 1, 3, 5, 5, 2, 1, 4, 3, 0, 2, 0, 2, 1, 3, 1, 1, 5, 2, 3, 1, 4, 0, 0, 1, 4, 2, 4, 2, 4, 5, 2, 4, 0, 3, 3, 1, 4, 5, 3, 0, 1, 1, 1, 4, 2, 1, 3, 5, 5, 3, 3, 2, 1, 3, 4, 1, 3, 1, 0, 5, 5, 2, 0, 4, 0, 1, 3, 2, 0, 3, 1, 5, 4, 2, 2, 3, 0, 5, 2, 1]
        
        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 29)
        
    def test_MayNoCall(self):
        
        schedule = [1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 1, 4]
        daysOff = dict()
        noCall = dict()
        for x in range(1, 11):
            noCall[x] = [ 0 ]
        
        chromosome = [0, 0, 1, 3, 5, 0, 2, 1, 4, 0, 1, 2, 0, 2, 1, 0, 1, 5, 0, 0, 0, 1, 4, 1, 0, 1, 4, 2, 4, 2, 4, 5, 2, 4, 0, 3, 3, 1, 4, 5, 3, 0, 1, 1, 1, 4, 2, 1, 3, 5, 5, 3, 3, 2, 1, 3, 4, 1, 3, 1, 0, 5, 5, 2, 0, 4, 0, 1, 3, 2, 0, 3, 1, 5, 4, 2, 2, 3, 0, 5, 2, 1]
        
        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 0)
        
    def test_May2(self):
        
        schedule = [1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 1, 4]
        daysOff = dict()
        for x in range(1, 8):
            daysOff[x] = [ 0 ]
        noCall = dict()
        for x in range(1, 8):
            noCall[x] = [ 0 ]
        
        chromosome = [1, 1, 1, 3, 5, 1, 2, 1, 4, 1, 1, 2, 1, 2, 1, 1, 1, 5, 2, 3, 0, 1, 4, 1, 0, 1, 4, 2, 4, 2, 4, 5, 2, 4, 0, 3, 3, 1, 4, 5, 3, 0, 1, 1, 1, 4, 2, 1, 3, 5, 5, 3, 3, 2, 1, 3, 4, 1, 3, 1, 0, 5, 5, 2, 0, 4, 0, 1, 3, 2, 0, 3, 1, 5, 4, 2, 2, 3, 0, 5, 2, 1]
        
        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 14)
        
    def test_May3(self):
        
        schedule = [1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 1, 4]
        daysOff = dict()
        for x in range(1, 8):
            daysOff[x] = [ 0 ]
        noCall = dict()
        
        chromosome = [0, 
                      1, 0, 3, 5, 
                      1, 2, 0, 4, 
                      0, 1, 2, 
                      1, 0, 1, 
                      1, 1, 0, 
                      0, 
                      3, 0, 1, 4, 1, 0, 1, 4, 2, 4, 2, 4, 5, 2, 4, 0, 3, 3, 1, 4, 5, 3, 0, 1, 1, 1, 4, 2, 1, 3, 5, 5, 3, 3, 2, 1, 3, 4, 1, 3, 1, 0, 5, 5, 2, 0, 4, 0, 1, 3, 2, 0, 3, 1, 5, 4, 2, 2, 3, 0, 5, 2, 1]
        
        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 0)
        
    def test_May4(self):
        
        schedule = [1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 1, 4]
        daysOff = dict()
        for x in range(1, 8):
            daysOff[x] = [ 0 ]
        noCall = dict()
        
        chromosome = [0, 
                      1, 0, 3, 5, 
                      1, 2, 0, 4, 
                      0, 1, 2, 
                      1, 1, 1, 
                      1, 1, 0, 
                      0, 
                      3, 0, 1, 4, 1, 0, 1, 4, 2, 4, 2, 4, 5, 2, 4, 0, 3, 3, 1, 4, 5, 3, 0, 1, 1, 1, 4, 2, 1, 3, 5, 5, 3, 3, 2, 1, 3, 4, 1, 3, 1, 0, 5, 5, 2, 0, 4, 0, 1, 3, 2, 0, 3, 1, 5, 4, 2, 2, 3, 0, 5, 2, 1]
        
        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 1)
        
    def test_June1(self):
        
        schedule = [3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3]
        daysOff = dict()
        daysOff[3] = [ 0 ]
        daysOff[4] = [ 1 ]
        noCall = dict()
        noCall[5] = [ 0 ]
        noCall[6] = [ 1 ]
        noCall[19] = [ 1 ]
        noCall[20] = [ 1 ]
    
        chromosome = [3, 5, 0, 0, 2, 5, 2, 4, 1, 1, 4, 5, 1, 2, 3, 2, 1, 3, 4, 4, 1, 3, 1, 2, 3, 3, 2, 4, 4, 5, 2, 3, 4, 0, 4, 0, 3, 1, 5, 1, 2, 1, 0, 3, 3, 0, 5, 0, 1, 3, 0, 2, 5, 0, 1, 5, 2, 1, 0, 5, 3, 0, 5, 2, 5, 0, 0, 5, 2, 4, 0, 1, 4, 0, 5, 0, 5, 2, 0, 0, 2, 5]

        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 4)

    def test_June2(self):
        
        schedule = [3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3]
        daysOff = dict()
        daysOff[3] = [ 4 ]
        daysOff[4] = [ 1 ]
        noCall = dict()
        noCall[5] = [ 4 ]
        noCall[6] = [ 5 ]
    
        chromosome = [3, 5, 0, 
                      0, 2, 5, 
                      2, 4, 1, 
                      1, 
                      4, 
                      5, 1, 2, 3, 
                      2, 1, 3, 4, 
                      4, 1, 3, 1, 2, 3, 3, 2, 4, 4, 5, 2, 3, 4, 0, 4, 0, 3, 1, 5, 1, 2, 1, 0, 3, 3, 0, 5, 0, 1, 3, 0, 2, 5, 0, 1, 5, 2, 1, 0, 5, 3, 0, 5, 2, 5, 0, 0, 5, 2, 4, 0, 1, 4, 0, 5, 0, 5, 2, 0, 0, 2, 5]

        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 0)

    def test_June3(self):
        
        schedule = [3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 1, 4, 4, 3, 3]
        daysOff = dict()
        daysOff[3] = [ 4 ]
        daysOff[4] = [ 1 ]
        noCall = dict()
        noCall[5] = [ 4 ]
        noCall[6] = [ 5 ]
    
        chromosome = [3, 5, 0, 
                      0, 2, 5, 
                      2, 1, 1, 
                      1, 
                      2, 
                      3, 1, 2, 3, 
                      2, 1, 3, 4, 
                      4, 1, 3, 1, 2, 3, 3, 2, 4, 4, 5, 2, 3, 4, 0, 4, 0, 3, 1, 5, 1, 2, 1, 0, 3, 3, 0, 5, 0, 1, 3, 0, 2, 5, 0, 1, 5, 2, 1, 0, 5, 3, 0, 5, 2, 5, 0, 0, 5, 2, 4, 0, 1, 4, 0, 5, 0, 5, 2, 0, 0, 2, 5]

        score = VacationDaysEvaluator(schedule, daysOff, noCall, 1).evaluate(chromosome, False)
        
        self.assertEquals(score, 3)

if __name__ == '__main__':
    unittest.main()
